package com.bawei.livedata;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

/**
 * @Author : yaotianxue
 * @Time : On 2023/9/12 09:58
 * @Description : MyViewModel
 */
public class MyViewModel extends ViewModel {
//    public int num;
    private MutableLiveData<Integer> num;
    //获得livedata
    public MutableLiveData<Integer> getNum(){
        if(num == null){
            num = new MutableLiveData<>();
            num.setValue(0);
        }
        return num;
    }
}
